﻿using Entities;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using DataAccess;
using System.Collections.Generic;
using BusinessLogic;
using System.Data;


namespace TestMock1_G2
{
    [TestClass]
    public class UnitTest_Nhat
    {
        [TestMethod]
        public void UnittestCheckBalance()
        {
            CustomerDA cus_DA = new CustomerDA();
            CustomerEntites cus_E = new CustomerEntites();
            CardEntites card_E = new CardEntites();            
            card_E.CardNo = "1234567891234569";
            decimal exp = 183266789;
            decimal act = cus_DA.checkBalance(card_E);
            Assert.AreEqual(exp,act);
        }
        [TestMethod]
        public void UnitTest_TransferAccountReceive()
        {
            CustomerDA cus_DA = new CustomerDA();
            AccountEntites account_E = new AccountEntites();
            CardEntites card_E = new CardEntites();
            account_E.AccountID = 3;
            account_E.Balance = 100000;          
            bool act = cus_DA.TransferAccountReceive(account_E);
            Assert.IsTrue(act);
        }
        [TestMethod]
        public void UnitTest_Transfer()
        {
            CustomerDA cus_DA = new CustomerDA();
            AccountEntites account_E = new AccountEntites();
            
            account_E.AccountID = 3;
            account_E.Balance = 100000;
            bool act = cus_DA.Transfer(account_E);
            Assert.IsTrue(act);
        }
        [TestMethod]
        public void UnitTest_GetNameReceive()
        {
            CustomerDA cus_DA = new CustomerDA();
            AccountEntites account_E = new AccountEntites();
            account_E.AccountID = 3;
            DataTable exp = new DataTable();
            exp.Columns.Add("Name");
            exp.Columns.Add("AccountID");           
            DataTable act = CustomerDA.GetNameReceive(account_E);
            Assert.IsTrue(CompareDataTables(exp,act));
        }
        [TestMethod]
        public void UnitTest_GetName()
        {
            CustomerDA cus_DA = new CustomerDA();
            CardEntites card_E = new CardEntites();
            card_E.CardNo = "1234567891234569";
            DataTable exp = new DataTable();
            exp.Columns.Add("Name");           
            DataTable act = CustomerDA.GetName(card_E);
            Assert.IsTrue(CompareDataTables(exp, act));
        }
        public static bool CompareDataTables(DataTable DT1, DataTable DT2)
        {
            if ((DT1 == null) && (DT2 == null))
            {
                return true;
            }
            else if ((DT1 != null) && (DT2 != null))
            {
                return true;
            }
            else
                return false;    
                       
          }
               
     }
 }

